<template>
  <el-descriptions
    :class="[
      'custom-descriptions',
      { 'kefu-descriptions': column === 1 },
      `columns-${column}`  // 动态添加列数对应的类
    ]"
    :column="column"
    border
  >
    <!-- 内容保持不变 -->
    <el-descriptions-item>
      <template #label>
        <descriptions-item-label icon="ep:suitcase" label=" 类型 " />
      </template>
      {{ user.groupName || '-' }}
    </el-descriptions-item>

    <el-descriptions-item :span="column">
      <template #label>
        <descriptions-item-label icon="ep:coin" label=" 标签 " />
      </template>
      <div class="long-text-container">
        {{ user.point || 0 }}
      </div>
    </el-descriptions-item>
  </el-descriptions>
</template>

<script lang="ts" setup>
import { DescriptionsItemLabel } from '@/components/Descriptions'
import * as UserApi from '@/api/member/user'

withDefaults(defineProps<{
  user: UserApi.UserVO;
  column?: number
}>(), {
  column: 2
})
</script>

<style lang="scss" scoped>
// 基础样式保持不变
.cell-item {
  display: inline;
}

.cell-item::after {
  content: ':';
}

.kefu-descriptions {
  ::v-deep(.el-descriptions__cell) {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    vertical-align: top;

    .el-descriptions__label {
      width: 120px;
      display: block;
      text-align: left;
      padding-top: 5px;
    }

    .el-descriptions__content {
      flex: 1;
      text-align: end;
      word-break: break-word;
      padding-top: 5px;
    }
  }
}

.long-text-container {
  max-width: 100%;
  line-height: 1.6;
}

// 修复边框样式 - 使用静态类处理不同列数
::v-deep(.custom-descriptions.el-descriptions--border) {
  .el-descriptions__row {
    border-bottom: 1px solid #eee;
    &:last-child {
      border-bottom: none;
    }
  }

  .el-descriptions__cell {
    border-right: 1px solid #eee;
  }

  // 2列布局时，第2、4、6...列无边框
  &.columns-2 {
    .el-descriptions__cell:nth-child(2n) {
      border-right: none;
    }
  }

  // 3列布局时，第3、6、9...列无边框
  &.columns-3 {
    .el-descriptions__cell:nth-child(3n) {
      border-right: none;
    }
  }

  // 1列布局时，所有列都无边框（因为独占一行）
  &.columns-1 {
    .el-descriptions__cell {
      border-right: none;
    }
  }
}
</style>
